#include <stdio.h>
#include <stdlib.h>

#include "dulinklist.h"

void visit(ElemType e)
{
    printf("%d\t",e);
}

int main()
{
    DuLinkList me;
    int ret,i;

    ret = InitList(&me);
    if (ret != OK)
    {
        printf("List init fail!\n");
        exit(0);
    }

    for ( i = 0; i < 5; i++)
    {
        ret = ListInsert(me,i,i);
        if (ret != OK)
        {
            printf("list insert fail!\n");
            break;
        }
    }
/**
    ret = ListLength(me);
    printf("list length is %d\n",ret);
*/

    ret = ListInsert(me,2,45);
    if (ret!=OK)
    {
        printf("elem insert fail!\n");
    }

    ListTraverse(me,visit);
/**
    ElemType temp;
    ret = GetElem(me,3,&temp);
    if (ret!=OK)
    {
        printf("get elem fail!\n");
    }else{
        printf("temp = %d\n",temp);
    }
*/

/**
    ret = ListEmpty(me);
    printf("ret = %d\n",ret);

    ClearList(me);

    ListTraverse(me,visit);
    ret = ListEmpty(me);
    printf("ret = %d\n",ret);
*/

/**
    ret = ListInsert(me,5,44);
    printf("ret = %d\n",ret);

    ListTraverse(me,visit);
*/

/**
    ElemType temp;
    ret = ListDelete(me,5,&temp);
    if (ret!=OK)
    {
        printf("elem delete fail!\n");
    }else{
        printf("delete elem is %d\n",temp);
    }
*/
    DestroyList(&me);
    
    exit(0);
}